package com.ruoyi.drive.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.drive.domain.Driver;
import com.ruoyi.drive.domain.DrivingLicenseInfo;
import com.ruoyi.drive.domain.IdCardInfo;
import com.ruoyi.drive.domain.VehicleLicenseInfo;
import com.ruoyi.drive.ocrUnits.OcrUnit;
import com.ruoyi.drive.service.DriverService;
import com.ruoyi.drive.service.Impl.DriverServiceImpl;

import com.ruoyi.system.api.model.LoginUser;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

/**
* (driver)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/driver")
public class DriverController {
/**
* 服务对象
*/
    @Autowired
    private DriverService driverService;


    /**
     * 身份证识别
     */
    @PostMapping("/ocrIdentification")
    public R<IdCardInfo> ocrIdentification(@RequestParam("file") MultipartFile file){
        String result = OcrUnit.ocrIdentification(1,file);
        IdCardInfo idCardInfo = OcrUnit.parseIdCardInfo(result);
        return R.ok(idCardInfo);
    }
    /**
     * 驾驶证识别
     */
    @PostMapping("/ocrDriverLicense")
    public R<DrivingLicenseInfo> ocrDriverLicense(@RequestParam("file") MultipartFile file) {
        String result = OcrUnit.ocrIdentification(2, file);
        DrivingLicenseInfo drivingLicenseInfo = OcrUnit.parseDrivingLicenseInfo(result);
        return R.ok(drivingLicenseInfo);
    }
    /**
     * 行驶证识别
     */
    @PostMapping("/ocrVehicleLicense")
    public R<VehicleLicenseInfo> ocrVehicleLicense(@RequestParam("file") MultipartFile file) {
        String result = OcrUnit.ocrIdentification(3, file);
        VehicleLicenseInfo vehicleLicenseInfo = OcrUnit.parseVehicleLicenseInfo(result);
        return R.ok(vehicleLicenseInfo);
    }
}